Source for file SC_UploadFile.php
Documentation is available at SC_UploadFile.php
* This file is part of EC-CUBE
* Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved.
* http://www.lockon.co.jp/
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
require_once $ownDir . '../module/gdthumb.php';
function addFile($disp_name, $keyname, $arrExt, $size, $necessary= false, $width= 0, $height= 0, $image= true) {
function makeThumb($src_file, $width, $height, $dst_file) {
$objThumb = new gdthumb();
$ret = $objThumb->Main($src_file, $width, $height, $dst_file);
$objErr = new SC_CheckError_Ex();
if(!($_FILES[$keyname]['size'] > 0)) {
$objErr->arrErr[$keyname] = "※ " . $this->disp_name[$arrKeyname[$keyname]] . "がアップロードされていません。<br />";
$objErr->doFunc(array($this->disp_name[$cnt], $keyname, $this->arrExt[$cnt]), array("FILE_EXT_CHECK"));
$objErr->doFunc(array($this->disp_name[$cnt], $keyname, $this->size[$cnt]), array("FILE_SIZE_CHECK"));
if(!isset ($objErr->arrErr[$keyname])) {
$this->temp_file[$cnt] = $_FILES[$keyname]['name'];
GC_Utils_Ex::gfPrintLog($_FILES[$keyname]['name']. " -> ". $this->temp_dir . $this->temp_file[$cnt]);
$objErr->arrErr[$keyname] = '※ ファイルのアップロードに失敗しました。<br />';
GC_Utils_Ex::gfPrintLog('File Upload Error!: ' . $_FILES[$keyname]['name']. " -> ". $this->temp_dir . $this->temp_file[$cnt]);
return $objErr->arrErr[$keyname];
// アップロードされたダウンロードファイルを保存する。
$objErr = new SC_CheckError_Ex();
if(!($_FILES[$keyname]['size'] > 0)) {
$objErr->arrErr[$keyname] = "※ " . $this->disp_name[$arrKeyname[$keyname]] . "がアップロードされていません。(ファイルがアップロードできない場合は、.htaccessファイルのphp_value upload_max_filesizeを調整してください)<br />";
$objErr->doFunc(array($this->disp_name[$cnt], $keyname, $this->arrExt[$cnt]), array("FILE_EXT_CHECK"));
$objErr->doFunc(array($this->disp_name[$cnt], $keyname, $this->size[$cnt]), array("FILE_SIZE_CHECK"));
if(!isset ($objErr->arrErr[$keyname])) {
return $objErr->arrErr[$keyname];
$objImage = new SC_Image_Ex($this->temp_dir);
$objImage = new SC_Image_Ex($this->temp_dir);
//$this->save_file[$cnt] = "";
$objImage = new SC_Image_Ex($this->temp_dir);
// ダウンロード一時ファイルを保存ディレクトリに移す
$objImage = new SC_Image_Ex($this->temp_dir);
$arrRet["temp_" . $val] = $this->temp_file[$cnt];
$arrRet["save_" . $val] = $this->save_file[$cnt];
// HIDDENで送られてきたファイル名を取得する
if(isset ($arrPOST[$key]) && !empty($arrPOST[$key])) {
if(isset ($arrPOST[$key]) && !empty($arrPOST[$key])) {
if(isset ($arrPOST[$key])) {
if(isset ($arrPOST[$key]) && !empty($arrPOST[$key])) {
// ファイルパスチェック(パスのスラッシュ/が連続しないようにする。)
if(ereg("/$", $temp_url)) {
$arrRet[$val]['filepath'] = $temp_url . $this->temp_file[$cnt];
$arrRet[$val]['filepath'] = $temp_url . "/" . $this->temp_file[$cnt];
// ファイルパスチェック(パスのスラッシュ/が連続しないようにする。)
if(ereg("/$", $save_url)) {
$arrRet[$val]['filepath'] = $save_url . $this->save_file[$cnt];
$arrRet[$val]['filepath'] = $save_url . "/" . $this->save_file[$cnt];
if(isset ($arrRet[$val]['filepath']) && !empty($arrRet[$val]['filepath'])) {
if(is_file($arrRet[$val]['real_filepath'])) {
list ($width, $height) = getimagesize($arrRet[$val]['real_filepath']);
$arrRet[$val]['width'] = $width;
$arrRet[$val]['height'] = $height;
$arrRet[$val]['width'] = $this->width[$cnt];
$arrRet[$val]['height'] = $this->height[$cnt];
$arrRet[$val]['disp_name'] = $this->disp_name[$cnt];
// フォームに渡す用のダウンロードファイル情報を返す
if(isset ($arrVal[$val]) && $arrVal[$val] != "") {
// DBで保存されたダウンロードファイル名をセットする
if(isset ($arrVal['down_realfilename']) && $arrVal['down_realfilename'] != "") {
$this->save_file[0] = $arrVal['down_realfilename'];
// DBで保存されたダウンロードファイル名をセットする(setDBDownFileと統合予定)
if(isset ($arrPost['temp_down_realfilename:' . ($cnt+ 1)])) {
$this->temp_file[$cnt] = $arrPost['temp_down_realfilename:' . ($cnt+ 1)];
if($arrVal[$val] != "" && $val == 'tv_products_image') {
// DB上のファイルの内削除要求があったファイルを削除する。
$objImage = new SC_Image_Ex($this->temp_dir);
if($arrVal[$val] != "") {
if($this->save_file[$cnt] == "" && !ereg("^sub/", $arrVal[$val])) {
$objImage->deleteImage($arrVal[$val], $this->save_dir);
// DB上のダウンロードファイルの内削除要求があったファイルを削除する。
$objImage = new SC_Image_Ex($this->temp_dir);
if($arrVal['down_realfilename'] != "") {
if($this->save_file[$cnt] == "" && !ereg("^sub/", $arrVal['down_realfilename'])) {
$objImage->deleteImage($arrVal['down_realfilename'], $this->save_dir);
if($val == $keyname || $keyname == "") {
$arrRet[$val] = "※ " . $this->disp_name[$cnt] . "がアップロードされていません。<br>";
$file = $this->temp_file[$arrImageKey[$keyname]];
$path = $this->makeThumb($filepath, $to_w, $to_h);
$uploadfile = strlen($uploadfile) > 0 ? $uploadfile : $_FILES[$keyname]['name'];
$uniqname = preg_replace('/(.+)\.(.+?)$/','$1', $uploadfile);
$dst_file = $this->temp_dir . $uniqname;
Documentation generated on Fri, 24 Feb 2012 14:02:59 +0900 by Seasoft
|